/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.dengues.model.warehouse.impl;

import java.util.Collection;

import org.dengues.model.warehouse.ElementParameterType;
import org.dengues.model.warehouse.MetadataType;
import org.dengues.model.warehouse.NodeType;
import org.dengues.model.warehouse.WarehousePackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Node Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.warehouse.impl.NodeTypeImpl#getMetadata <em>Metadata</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.NodeTypeImpl#getElementParameter <em>Element Parameter</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.NodeTypeImpl#getColor <em>Color</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.NodeTypeImpl#getCompName <em>Comp Name</em>}</li>
 *   <li>{@link org.dengues.model.warehouse.impl.NodeTypeImpl#getStringData <em>String Data</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class NodeTypeImpl extends AbstractCompElementImpl implements NodeType {
    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static final String copyright = "// ============================================================================\r\n//\r\n// Copyright (C) 2006-2007 Dengues\r\n//\r\n// Google Group: http://groups.google.com/group/dengues\r\n// QQ Group: 24885404\r\n//\r\n// This library is free software; you can redistribute it and/or\r\n// modify it under the terms of the GNU Lesser General Public\r\n// License as published by the Free Software Foundation; either\r\n// version 2.1 of the License.\r\n//\r\n// This library is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r\n// Lesser General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with this program; if not, write to the Free Software\r\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r\n//\r\n// ============================================================================\r\n";

    /**
     * The cached value of the '{@link #getMetadata() <em>Metadata</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getMetadata()
     * @generated
     * @ordered
     */
    protected EList<MetadataType> metadata;

    /**
     * The cached value of the '{@link #getElementParameter() <em>Element Parameter</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getElementParameter()
     * @generated
     * @ordered
     */
    protected EList<ElementParameterType> elementParameter;

    /**
     * The default value of the '{@link #getColor() <em>Color</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getColor()
     * @generated
     * @ordered
     */
    protected static final int COLOR_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getColor() <em>Color</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getColor()
     * @generated
     * @ordered
     */
    protected int color = COLOR_EDEFAULT;

    /**
     * This is true if the Color attribute has been set.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     * @ordered
     */
    protected boolean colorESet;

    /**
     * The default value of the '{@link #getCompName() <em>Comp Name</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getCompName()
     * @generated
     * @ordered
     */
    protected static final String COMP_NAME_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getCompName() <em>Comp Name</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getCompName()
     * @generated
     * @ordered
     */
    protected String compName = COMP_NAME_EDEFAULT;

    /**
     * The default value of the '{@link #getStringData() <em>String Data</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getStringData()
     * @generated
     * @ordered
     */
    protected static final String STRING_DATA_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getStringData() <em>String Data</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getStringData()
     * @generated
     * @ordered
     */
    protected String stringData = STRING_DATA_EDEFAULT;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected NodeTypeImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return WarehousePackage.Literals.NODE_TYPE;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<MetadataType> getMetadata() {
        if (metadata == null) {
            metadata = new EObjectContainmentEList<MetadataType>(MetadataType.class, this, WarehousePackage.NODE_TYPE__METADATA);
        }
        return metadata;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<ElementParameterType> getElementParameter() {
        if (elementParameter == null) {
            elementParameter = new EObjectContainmentEList<ElementParameterType>(ElementParameterType.class, this, WarehousePackage.NODE_TYPE__ELEMENT_PARAMETER);
        }
        return elementParameter;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getColor() {
        return color;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setColor(int newColor) {
        int oldColor = color;
        color = newColor;
        boolean oldColorESet = colorESet;
        colorESet = true;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, WarehousePackage.NODE_TYPE__COLOR, oldColor, color, !oldColorESet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void unsetColor() {
        int oldColor = color;
        boolean oldColorESet = colorESet;
        color = COLOR_EDEFAULT;
        colorESet = false;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.UNSET, WarehousePackage.NODE_TYPE__COLOR, oldColor, COLOR_EDEFAULT, oldColorESet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public boolean isSetColor() {
        return colorESet;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getCompName() {
        return compName;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setCompName(String newCompName) {
        String oldCompName = compName;
        compName = newCompName;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, WarehousePackage.NODE_TYPE__COMP_NAME, oldCompName, compName));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getStringData() {
        return stringData;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setStringData(String newStringData) {
        String oldStringData = stringData;
        stringData = newStringData;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, WarehousePackage.NODE_TYPE__STRING_DATA, oldStringData, stringData));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case WarehousePackage.NODE_TYPE__METADATA:
                return ((InternalEList<?>)getMetadata()).basicRemove(otherEnd, msgs);
            case WarehousePackage.NODE_TYPE__ELEMENT_PARAMETER:
                return ((InternalEList<?>)getElementParameter()).basicRemove(otherEnd, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case WarehousePackage.NODE_TYPE__METADATA:
                return getMetadata();
            case WarehousePackage.NODE_TYPE__ELEMENT_PARAMETER:
                return getElementParameter();
            case WarehousePackage.NODE_TYPE__COLOR:
                return new Integer(getColor());
            case WarehousePackage.NODE_TYPE__COMP_NAME:
                return getCompName();
            case WarehousePackage.NODE_TYPE__STRING_DATA:
                return getStringData();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @SuppressWarnings("unchecked")
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case WarehousePackage.NODE_TYPE__METADATA:
                getMetadata().clear();
                getMetadata().addAll((Collection<? extends MetadataType>)newValue);
                return;
            case WarehousePackage.NODE_TYPE__ELEMENT_PARAMETER:
                getElementParameter().clear();
                getElementParameter().addAll((Collection<? extends ElementParameterType>)newValue);
                return;
            case WarehousePackage.NODE_TYPE__COLOR:
                setColor(((Integer)newValue).intValue());
                return;
            case WarehousePackage.NODE_TYPE__COMP_NAME:
                setCompName((String)newValue);
                return;
            case WarehousePackage.NODE_TYPE__STRING_DATA:
                setStringData((String)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case WarehousePackage.NODE_TYPE__METADATA:
                getMetadata().clear();
                return;
            case WarehousePackage.NODE_TYPE__ELEMENT_PARAMETER:
                getElementParameter().clear();
                return;
            case WarehousePackage.NODE_TYPE__COLOR:
                unsetColor();
                return;
            case WarehousePackage.NODE_TYPE__COMP_NAME:
                setCompName(COMP_NAME_EDEFAULT);
                return;
            case WarehousePackage.NODE_TYPE__STRING_DATA:
                setStringData(STRING_DATA_EDEFAULT);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case WarehousePackage.NODE_TYPE__METADATA:
                return metadata != null && !metadata.isEmpty();
            case WarehousePackage.NODE_TYPE__ELEMENT_PARAMETER:
                return elementParameter != null && !elementParameter.isEmpty();
            case WarehousePackage.NODE_TYPE__COLOR:
                return isSetColor();
            case WarehousePackage.NODE_TYPE__COMP_NAME:
                return COMP_NAME_EDEFAULT == null ? compName != null : !COMP_NAME_EDEFAULT.equals(compName);
            case WarehousePackage.NODE_TYPE__STRING_DATA:
                return STRING_DATA_EDEFAULT == null ? stringData != null : !STRING_DATA_EDEFAULT.equals(stringData);
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (color: ");
        if (colorESet) result.append(color); else result.append("<unset>");
        result.append(", compName: ");
        result.append(compName);
        result.append(", stringData: ");
        result.append(stringData);
        result.append(')');
        return result.toString();
    }

} //NodeTypeImpl
